package com.mark.util;

import com.mark.enums.PropertiesEnum;

/**
 * Created by Mark on 2018/4/12.
 * 路径处理工具类
 */
public class PathUtil{

    private static String separator = System.getProperty(PropertiesEnum.FILE_SEPARATOR.getPropertiesName());//获取文件的分流符号
    private static String basePathWin= PropertiesUtil.getProperty(PropertiesEnum.BASE_PATH_WIN.getPropertiesName());
    private static String basePathOther= PropertiesUtil.getProperty(PropertiesEnum.BASE_PATH_OTHER.getPropertiesName());
    private static String productPath= PropertiesUtil.getProperty(PropertiesEnum.PRODUCT_PATH.getPropertiesName());
    private static String categoryPath= PropertiesUtil.getProperty(PropertiesEnum.CATEGORY_PATH.getPropertiesName());
    private static String  headLinePath= PropertiesUtil.getProperty(PropertiesEnum.HEADLINE_PATH.getPropertiesName());
    private static String  simditorPath= PropertiesUtil.getProperty(PropertiesEnum.SIMDITOR_PATH.getPropertiesName());
    private static String  getQrPath= PropertiesUtil.getProperty(PropertiesEnum.getQrPath.getPropertiesName());
    private static String userPath= PropertiesUtil.getProperty(PropertiesEnum.USER_PATH.getPropertiesName());

    public static String getImageBasePath() {
        String os = System.getProperty("os.name");
        String basePath ;
        if (os.toLowerCase().startsWith("win")) {
            basePath = basePathWin;
        } else {
            basePath = basePathOther;
        }
        basePath = basePath.replace("/", separator);
        return basePath;
    }

    public static String getProductImagePath(long productId) {
        String imagePath = productPath + productId + "/";
        return imagePath.replace("/", separator);
    }
    public static String getUserImageath(long userId){
        String imagePath = userPath + userId + "/";
        return imagePath.replace("/", separator);
    }
    public static String getCategoryImagePath() { //返回商品种类图片保存的路径
        String imagePath = categoryPath + "/";
        return imagePath.replace("/", separator);
    }
    public static String getHeadLineImagePath() { //返回公告信息图片保存的路径
        String imagePath = headLinePath + "/";
        return imagePath.replace("/", separator);
    }
    public static String getSimditorImagePath() { //返回富文本插件中上传图片保存的路径
        String imagePath = simditorPath + "/";
        return imagePath.replace("/", separator);
    }
    //返回二维码的路径
    public static String getQrPath(){
        String imagePath = getQrPath + "/";
        return imagePath.replace("/", separator);
    }



}
